package com.fastjrun.ciagent.mojo;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

import com.fastjrun.ciagent.ModuleGenerator;


public abstract class CommonGCMojo extends AbstractMojo {
    /**
     * 
     * @parameter property="commongc.accessKey" default-value="accessKey"
     */

    protected String accessKey;
    /**
     * 
     * @parameter property="commongc.accessKeySn" default-value="accessKeySn"
     */

    protected String accessKeySn;
    /**
     * 
     * @parameter property="commongc.apiUrlPre" default-value="apiUrlPre"
     */

    protected String apiUrlPre;
    /**
     * 
     * @parameter property="commongc.appName" default-value="apiworld"
     */

    protected String appName;
    /**
     * 
     * @parameter property="commongc.packagePrefix"
     *            default-value="com.fastjrun.demo."
     */

    protected String packagePrefix;

    /**
     * 
     * @parameter property="commongc.projectDir" default-value="."
     */

    protected String projectDir;

    /**
     * 
     * @parameter property="commongc.skip" default-value="true"
     */

    protected boolean skip;

    /**
     * 
     * @parameter property="commongc.tmpWorkSpace" default-value="/tmp/ciAgent"
     */

    protected String tmpWorkSpace;

    protected void execute(String moduleName,String srcFile,String codeDir) throws MojoExecutionException {

        ModuleGenerator simpleClientGenerator = new ModuleGenerator();
        simpleClientGenerator.setModuleName(moduleName);
        simpleClientGenerator.setAccessKey(accessKey);
        simpleClientGenerator.setAccessKeySn(accessKeySn);
        simpleClientGenerator.setApiUrlPre(apiUrlPre);
        simpleClientGenerator.setSrcFile(srcFile);
        simpleClientGenerator.setCodeDir(codeDir);
        simpleClientGenerator.setPackagePrefix(packagePrefix);
        simpleClientGenerator.setAppName(appName);
        simpleClientGenerator.setTmpWorkSpace(tmpWorkSpace);
        simpleClientGenerator.setProjectDir(projectDir);
        simpleClientGenerator.init();
        try {
            simpleClientGenerator.generate();
        } catch (Exception e) {
            getLog().error("", e);
        }
    }
}
